package com.lmk.sc.web;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.lmk.sc.entity.User;
import com.lmk.sc.service.FeignUserService;

/**
 * 使用Feign客户端发起服务调用
 */
@RestController
@RequestMapping("/consumer/user")
public class UserController {

    @Autowired
    FeignUserService feignUserService;

    @GetMapping("")
    public List<User> list(){
        return feignUserService.list();
    }

    @GetMapping("{id}")
    public User get(@PathVariable("id") Integer id){
        return feignUserService.get(id);
    }

    @DeleteMapping("{id}")
    public Map<String, Object> delete(@PathVariable("id") Integer id){
        return feignUserService.delete(id);
    }

    @PostMapping("")
    public Map<String, Object> post(@RequestBody Map<String, Object> user){
        return feignUserService.post(user);
    }

    @PutMapping("")
    public Map<String, Object> put(@RequestBody Map<String, Object> user){
        return feignUserService.put(user);
    }
}
